
let routerList = ['/login','/home']
setRouterList()
// 获取权限菜单
function setRouterList() {
    const menuList = JSON.parse(localStorage.getItem('userRoles'))
    if (menuList) {
        menuList.map(function (item) {
            if(item.children){
                item.children.map(function(val){
                    if(routerList.indexOf(val.path) == -1){
                        routerList.push(val.path)
                    }
                })
            }else{
                routerList.push(item.path)
            }
        })
    }
}
// 页面跳转前校验  判断将要跳转的路径是否在权限表中
const getPermission = function (path) {
    let type = false
    if (routerList && path) {
        if (routerList.indexOf(path) == -1) {
            type = false
        } else {
            type = true
        }
    }
    return type
}

export {
    getPermission
}